package org.way;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.way.rocketMq.bean.RocketMqProperties;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Slf4j
@MapperScan("org.way.*.mapper")
@SpringBootApplication(scanBasePackages = {"org.way.*"})
@EnableSwagger2
@EnableAsync
public class WayStartApplication {

	public static void main(String[] args) {
		ConfigurableApplicationContext context = SpringApplication.run(WayStartApplication.class, args);
		ConfigurableEnvironment environment = context.getEnvironment();
		String swaggerDocUrl = "localhost:" + environment.getProperty("server.port") + environment.getProperty("server.servlet.context-path")
				+ "/doc.html";
		String swaggerUi = "localhost:" + environment.getProperty("server.port") + environment.getProperty("server.servlet.context-path")
				+ "/swagger-ui.html";
		log.info("swagger ui url: {}", swaggerUi);
		log.info("swagger doc url: {}", swaggerDocUrl);

		RocketMqProperties mqProperties = context.getBean(RocketMqProperties.class);
		log.info("current environment topic: {}, consumerGroup: {}",mqProperties.getTopic(),mqProperties.getGroup());

	}

}
